import { Body, Controller, Post, Put } from '@nestjs/common';
// import { UserService } from '../user/user.service';
import { Get } from '@nestjs/common';
import { MenuService } from './menu.service';
import type { Menu } from './menu.entity';
// import { Req } from '@nestjs/common';
// import type { Request } from 'express';
@Controller('menu')
export class MenuController {
  constructor(private readonly menuService: MenuService) {}
  // 获取全部路由
  @Get('/')
  async getMenu() {
    return await this.menuService.findAll();
  }

  // 新增路由
  @Post('/')
  async create(@Body() body: Menu) {
    return await this.menuService.create(body);
  }
  // 更新路由
  @Put('/')
  async update(@Body() body: Menu) {
    return await this.menuService.update(body);
  }
  // 获取启用的路由
  @Get('/enable')
  async getEnabledMenu() {
    return await this.menuService.findEnabled();
  }
}
